package cn.liye.pingfen.controller;

import cn.liye.pingfen.pojo.dto.CityDTO;
import cn.liye.pingfen.pojo.dto.ProvinceDTO;
import cn.liye.pingfen.pojo.vo.SysRegionVO;
import cn.liye.pingfen.response.JsonResult;
import cn.liye.pingfen.service.ICityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "省市")
@Validated
@Slf4j
@RestController
@RequestMapping("/v1/city")
public class CityController {

    @Autowired
    ICityService iCityService;

    @ApiOperation("省市二级联动")
    @GetMapping("/address")
    public JsonResult listForIndex() {
        List<ProvinceDTO> list = iCityService.selectCityInfo();
        System.out.println(list);
        return JsonResult.ok(list);
    }


    @ApiOperation("查询省")
    @GetMapping("/pro")
    public JsonResult listForPro() {
        List<ProvinceDTO> list = iCityService.selectPro();
        System.out.println(list);
        return JsonResult.ok(list);
    }


    @ApiOperation("查询市")
    @GetMapping("/city")
    public JsonResult listForCity(String regionParentId) {
        List<CityDTO> list = iCityService.selectCity(regionParentId);
        System.out.println(list);
        return JsonResult.ok(list);
    }

}